package classes;

import java.awt.AWTException;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Robot;
import java.awt.event.KeyEvent;

public class MoveMouse {

	/**
	 * @param args
	 * @throws AWTException
	 * @throws InterruptedException
	 */

	public static void main(String[] args) throws AWTException,
			InterruptedException {

		CoordenadaVerts vert = new CoordenadaVerts();
		Robot r = new Robot();
		while (true) {
			vert.clica(r);
			r.keyPress(KeyEvent.VK_SPACE);
			r.delay(50);
			r.keyRelease(KeyEvent.VK_SPACE);
			r.delay(500);

		}

	}

	public void altTab(Robot r) {
		r.keyPress(KeyEvent.VK_ALT);
		r.delay(50);
		r.keyPress(KeyEvent.VK_TAB);
		r.delay(50);
		r.keyRelease(KeyEvent.VK_TAB);
		r.delay(50);
		r.keyRelease(KeyEvent.VK_ALT);
		r.delay(50);
	}

	public void rotinaPaidVerts(Robot r, CoordenadaVerts vert) {
		altTab(r);
		vert.posicionaMouse(r);
		vert.clica(r);
		r.delay(2000);
		if (verificaAnuncio(r) == -1) {
			vert.copiaTestes1(r);
		} else {
			vert.copiaTestes2(r);
		}

		vert.clicaCaptcha(r);
	}

	public Point posicao() {
		return MouseInfo.getPointerInfo().getLocation();
	}

	public int verificaAnuncio(Robot r) {
		int pixel = r.getPixelColor(829, 794).getRGB();
		return pixel;
	}
}
